package com.syscom.admin.controller;

import com.syscom.admin.service.SysMenuService;
import com.syscom.common.entity.SysMenu;
import com.syscom.common.utils.result.AjaxResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author wjz
 * @Date 2020-12-28
 */
@RestController
@RequestMapping("/sysMenu")
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;

    @ApiOperation("SysMenu查询接口")
    @GetMapping("/queryAllMenu")
    public AjaxResult queryAllMenu() {

        return sysMenuService.queryAllMenu();
    }

    @ApiOperation("通过id查询")
    @GetMapping("/queryMenuById")
    public AjaxResult queryMenuById(Long objectId) {

        return sysMenuService.queryMenuById(objectId);
    }

    @ApiOperation("SysMenu新增接口")
    @PostMapping("/addSysMenu")
    public AjaxResult addSysMenu(@RequestBody SysMenu sysMenu) {

        return sysMenuService.addSysMenu(sysMenu);
    }

    @ApiOperation("SysMenu更新接口")
    @PatchMapping("/updateSysMenu/{objectId}")
    public AjaxResult updateSysMenu(@PathVariable Long objectId, @RequestBody SysMenu sysMenu) {

        sysMenu.setObjectId(objectId);
        return sysMenuService.updateSysMenu(sysMenu);
    }

    @ApiOperation("SysMenu删除接口")
    @DeleteMapping("/deleteSysMenu/{objectId}")
    public AjaxResult deleteSysMenu(@PathVariable Long objectId) {

        return sysMenuService.deleteSysMenu(objectId);
    }

}

